<?php
$baseDir=prepareDir((getBaseDir())."/");
if(file_exists($baseDir.'includes/HhlException.php')){
	require_once($baseDir."includes/HhlException.php");
}
if(file_exists($baseDir.'includes/autoload.php')){
	require_once($baseDir."includes/autoload.php");
}
?>
<?php
function __autoload($class){
	$autoload = new autoload();
	$file = $autoload->findFile($class);
	if(file_exists($file)){
		require_once($file);
	}
}
 function getBaseDir($dir=''){
	if($dir==''){
		$currentScript = $_SERVER['PHP_SELF'];
		$currentFileArray = explode("/",$currentScript);
		if(count($currentFileArray)!=2){
			//var_dump($currentFileArray);
			$baseDir =$_SERVER['DOCUMENT_ROOT']."/".$currentFileArray[1];
		}else{
			$baseDir=$_SERVER['DOCUMENT_ROOT'];
		}
		return $baseDir;
	}else{
		return $dir;
	}
}
function prepareDir($dir){
	if (stripos($dir,"//",0)){
		$replecePattern ="|\/\/|";
		$dir=preg_replace($replecePattern,'/',$dir);
	}
	if (stripos($dir,"\\",0)){
		$replecePattern ="|\\\\|";
		$dir=preg_replace($replecePattern,'/',$dir);
	}
	return $dir;
}
?>